const express = require("express")
const router = express.Router()
const { db, genid } = require("../db/DbUtils")

router.get("/test", async (req, res) => {
  // db.all("select * from `admin`", (err, rows) => {
  //   console.log(rows);
  // })
  // //下面这句话与上面那句话等价
  // db.async.all("select * from `admin`").then((res) => {
  //   console.log(res)
  // })

  //使用async  await  与上面两句等价
  let out = await db.async.all("select * from `admin`")

  res.send({
    id: genid.NextId(),
    out//相当于out:out
  })
})

module.exports = router